#ifndef LIST_HEAD_PTHREAD_H__
#define LIST_HEAD_PTHREAD_H__

#include <pthread.h>

#define offsetof(type,member) ((size_t)&((type *)0)->member)

#define container_of(ptr,type,member)({\
	(type *)((char * )ptr-offsetof(type,member));\
	})

#define list_entry(ptr,type,member) \
	container_of(ptr,type,member)

#define __list_for_each(pos,head)	\
	for(pos=(head)->next;pos!=(head);pos=pos->next)

struct list_head
{
	struct list_head *prev,*next;
//	pthread_mutex_t mut;
	pthread_rwlock_t rwlock;
//	pthread_cond_t cond;
};

int List_head_init(struct list_head *name);

int List_add_prev(struct list_head *new,struct list_head *head);

int List_add_tail(struct list_head *new,struct list_head *head);

int List_delete_node(struct list_head *node);

int List_destroy(struct list_head *head);

#endif
